package com.firstresponder.location;

import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class StartServiceReceiver extends BroadcastReceiver {
	@Override
	public void onReceive(Context context, Intent intent) {
		Log.i("StartServiceReceiver", "onReceive called");
		try {
			Intent locationServiceIntent = new Intent();
			ComponentName comp = new ComponentName(context.getPackageName(),
					LocationService.class.getName());
			LocationService.setServiceStatus(LocationService.PASSIVE_MODE);
			ComponentName service = context.startService(new Intent()
					.setComponent(comp));
			if (service == null) {
				Log.i("StartServiceReceiver", "Could not start service!!");
			} else {
				Log.i("StartServiceReceiver", "SERVICE STARTED!!");
			}
			context.startService(locationServiceIntent);
		} catch (Throwable t) {
			Log.e("StartServiceReceiver", Log.getStackTraceString(t));
		}
	}
}
